package com.shun.base.action;


import com.shun.base.service.IShunDictDataService;
import com.shun.base.vo.ShunDictData;
import com.shun.common.R;
import com.shun.common.page.ShunPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 字典数据表 前端控制器
 * </p>
 *
 * @author clever
 * @since 2021-10-03
 */
@Slf4j
@RestController
@RequestMapping("/base/dict/v1/")
public class ShunDictDataAction {

    @Autowired
    private IShunDictDataService shunDictDataService;

    /**
     * 根据字典类型获得字典数据
     * @param dictType
     * @return
     */
     @PostMapping("/getDict/{dictType}")
     public R getDictData(@PathVariable("dictType") String dictType){
         log.debug("dictType:{}",dictType);
         return shunDictDataService.getDictData(dictType);
     }

    /**
     * 新增字典数据
     * @param dictData
     * @return
     */
    @PostMapping("/add")
    public R addDict(@RequestBody ShunDictData dictData){
        log.debug("dictData:{}",dictData);
        return shunDictDataService.addDictData(dictData);
    }

    /**
     * 删除字典数据根据字典ID
     * @param dataId
     * @return
     */
    @GetMapping("/del/{dataId}")
    public R delDict(@PathVariable("dataId") String dataId){
        log.debug("dataId:{}",dataId);
        return shunDictDataService.delDictData(dataId);
    }

    /**
     * 字典数据分页
     * @param page
     * @return
     */
    @PostMapping("/page")
    public R pageDict(@RequestBody ShunPage page){
        log.debug("page:{}",page);
        return shunDictDataService.pageDict(page);
    }

    /**
     * 编辑字典数据
     * @param dictData
     * @return
     */
    @PostMapping("/edit")
    public R editDict(@RequestBody ShunDictData dictData){
        log.debug("dictData:{}",dictData);
        return shunDictDataService.editDictData(dictData);
    }
}

